<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>找回密码</title>
    <link rel="stylesheet" href="/css/back_pw.css?v=2018-3-15 18:25:42">
    <link rel="stylesheet" href="/css/common.css?v=2018-3-15 17:49:46">
    <script src="/js/jquery.min.js"></script>
</head>
<body>

<!-- 弹出层 -->

<div id="M_layer_box" style="display:none"></div>
<div class="mainRight s-m-box">
    <div class="title">忘记密码</div>

    <div class="w740">

        <div class="step step4 clearfix">
            <ul class="clearfix">
                <li class="active"><span>1</span>
                    <p>验证身份</p><b></b></li>
                <!-- 添加active就有下一步的效果 -->
                <li class="active"><span>2</span>
                    <p>重置密码</p><b></b></li>
                <li><span>3</span>
                    <p>完成</p><b></b></li>
            </ul>
        </div><!--/step-->

        <div class="tableForm">
            <table>
                <tbody><tr>
                    <td width="90">设置密码</td>
                    <td width="500">
                        <input type="password" class="ui_inp ui_inp_big" placeholder="设置您的登录密码" id="J-m-pass">
                        <p class="ui_message_son" id="j-m-pwd1" style="display: none;">请输入正确格式的密码</p>
                    </td>
                </tr>
                <tr>
                    <td>验证密码</td>
                    <td width="185">
                        <input type="password" class="ui_inp ui_inp_big" placeholder="再次输入您的登录密码" id="J-m-pass2">
                        <p class="ui_message_son" id="j-m-pwd2" style="display: none;">请输入正确格式的密码</p>
                    </td>

                </tr>

                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="确定" class="ui_btn disabled ui_org_btn" id="J-m-submit">
                    </td>
                </tr>
                </tbody></table>
        </div>


    </div><!--/w640-->


</div><!--/w640-->
<!--/mainRight-->
<script type="text/javascript">
    $(function(){
        function GetQueryString(name) {
            var u=window.location.search;
            u=decodeURIComponent(u);
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = u.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }
        var id=GetQueryString("id");
        var mobile=GetQueryString("mobile");

        if(null==id || null==mobile || id=="" || mobile==""){
            mLayerMsg("获取用户信息错误");
            setTimeout(function(){
                location.href="/login/index";
            },5000);
            return;
        }

        var pass1 = $('#J-m-pass');
        var pass2 = $('#J-m-pass2');
        var confirmBtn=$('#J-m-submit');
        var passFlag1 = false;
        var passFlag2 = false;
        pass1.keydown(function (ev) {
            if (ev.keyCode == 32) {
                ev.preventDefault();
                return false;
            }
        });

        pass2.keydown(function (ev) {
            if (ev.keyCode == 32) {
                ev.preventDefault();
                return false;
            }
        });


        pass1.blur(function () {
            if (this.value.length >= 6 && this.value.length <= 16 && this.value.indexOf(' ') == -1) {
                $(this).next().css({
                    display: 'none'
                });
                passFlag1 = true;
            }
            else {
                $(this).next().css({
                    display: 'block'
                });
                passFlag1 = false;
            }
        });

        pass2.blur(function () {
            if (this.value.length >= 6 && this.value.length <= 16 && this.value == pass1.val()) {
                $(this).next().css({
                    display: 'none'
                });
                confirmBtn.attr("class","ui_btn ui_org_btn");
                passFlag2 = true;
            }
            else {
                $(this).next().css({
                    display: 'block'
                });
                passFlag2 = false;
            }
        });

        confirmBtn.click(function(){
            if(passFlag1&&passFlag2){
                $.ajax({
                    url: '/findccount/doEdit',
                    type: 'POST',
                    dataType: 'json',
                    data: {'id':id,'mobile':mobile,'password':pass2.val()},
                    success: function (data) {
                        if (data.code == 200) {
                            window.location = '/findccount/ok';
                        } else {
                            mLayerMsg(data.message);
                        }
                    }

                });
            }
        });

        //mqz 类似layer.msg的不固定窗口提示文字
        function mLayerMsg(msg){

            //所有页面的提示框id固定
            var oBox=$('#M_layer_box');
            oBox.html(msg);

            oBox.css({
                display:'block'
            });

            setTimeout(function(){
                oBox.css({
                    display:'none'
                });
            },2000);
        }
    })
</script>
</body>
</html>